#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>

int main()
{
    char buffer[128];
    const char* str = "i like linux";

    int fd = open("bite",O_RDWR|O_CREAT|O_TRUNC,0666);
    if(fd < 0)
    {
        perror("open fail");
        return 1;
    }

    write(fd,str,strlen(str));
    lseek(fd,SEEK_SET,0);
    size_t n = read(fd,buffer,sizeof(buffer)-1);
    buffer[n] = '\0';
    printf("%s\n",buffer);
    close(fd);

    return 0;
}
